package cn.tedu.csmall.business.service.impl;

import cn.tedu.csmall.business.service.IBusinessService;
import cn.tedu.csmall.commons.pojo.order.dto.OrderAddDTO;
import cn.tedu.csmall.order.service.IOrderService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class BusinessServiceImpl implements IBusinessService {

    @DubboReference
    private IOrderService dubboOrderService;
    @GlobalTransactional
    @Override
    public void buy() {
        OrderAddDTO orderAddDTO=new OrderAddDTO();
        orderAddDTO.setUserId("UU100");
        orderAddDTO.setCount(100);
        orderAddDTO.setCommodityCode("pc100");
        orderAddDTO.setMoney(100);
        log.info("新增订单信息为{}",orderAddDTO);
        //dubbo调用，将上面实例化的对象生成订单，修改数据库
        dubboOrderService.orderAdd(orderAddDTO);
    }
}
